package com.wang.wangrpc.protocol;

import lombok.Getter;

/**
 * @Author 王子旭
 * @Date 2025/04/04 22:37
 * @Version 1.0
 */
@Getter
public enum ProtocolMessageTypeEnum {
    REQUEST(0),
    RESPONSE(1),
    HEART_BEAT(2),
    OTHERS(3);

    private final int key;

    ProtocolMessageTypeEnum(int key) {
        this.key = key;
    }

    public static ProtocolMessageTypeEnum getEnumByKey(int value) {
        for (ProtocolMessageTypeEnum anEnum : ProtocolMessageTypeEnum.values()) {
            if (anEnum.getKey() == value) {
                return anEnum;
            }
        }
        return null;
    }
}
